package net.hn.hnms.biz.plan.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.plan.request.ExecutionPriorityWorkReq;
import net.hn.hnms.biz.plan.service.IExecutionPriorityWorkService;
import net.hn.hnms.biz.plan.vo.ExecutionPriorityWorkVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "重点工作模块", tags = {"重点工作执行"})
@RestController
@RequestMapping("/execution/priorityWork")
public class ExecutionPriorityWorkController extends BaseController {

    @Resource
    private IExecutionPriorityWorkService executionPriorityWorkService;

    /**
     * 新增进尺产量执行
     */
    @ApiOperation("新增重点工作执行")
    @SaCheckPermission("execution:priorityWork:add")
    @PostMapping("/add")
    @Log(title = "新增重点工作执行", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody ExecutionPriorityWorkReq executionPriorityWork) {
        return toAjax(executionPriorityWorkService.insert(executionPriorityWork));
    }

    /**
     * 删除其他生产计划
     */
    @ApiOperation("删除重点工作执行")
    @SaCheckPermission("execution:priorityWork:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除重点工作执行", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        executionPriorityWorkService.deleteBatch(idList);
        return R.ok();
    }

    /**
     * 修改其他生产计划
     */
    @ApiOperation("修改重点工作执行")
    @SaCheckPermission("execution:priorityWork:update")
    @PutMapping("/update")
    @Log(title = "修改重点工作执行", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody ExecutionPriorityWorkReq executionPriorityWork) {
        executionPriorityWorkService.updateById(executionPriorityWork);
        return R.ok();
    }

    /**
     * 获取重点工作执行
     */
    @ApiOperation("获取重点工作执行分页列表")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<ResponsePage<ExecutionPriorityWorkVo>> page(ExecutionPriorityWorkReq executionPriorityWork, PageQuery pageQuery) {
        return R.ok(executionPriorityWorkService.selectPageList(executionPriorityWork, pageQuery));
    }

    /**
     * 获取进尺产量执行详情
     */
    @ApiOperation("获取重点工作执行详情")
    @GetMapping("/{id}")
    public R<ExecutionPriorityWorkVo> detail(@PathVariable("id") String id) {
        return R.ok(executionPriorityWorkService.selectDetailById(id));
    }

}
